/*
 * @Author: webcc
 * @Date: 2022-10-23 23:14:52
 * @LastEditTime: 2022-10-23 23:32:40
 * @email: webcc.coder@qq.com
 */
import React, { Component } from 'react'
import { Select } from 'antd'
import { reqGetChannelList } from 'api/channel'
export default class Channel extends Component {
    state = {
        channels: [],
    }
    render() {
        return (
            <div>
                <Select
                    placeholder="请选择文章频道"
                    style={{
                        width: 200,
                    }}
                    value={this.props.value}
                    onChange={this.props.onChange}
                >
                    {
                        this.state.channels.map(item => (<Select.Option key={item.id} value={item.id}>{item.name}</Select.Option>))
                    }
                </Select>
            </div>
        )
    }
    getChannelList = async () => {
        const res = await reqGetChannelList()
        this.setState({
            channels: res.data.channels
        })
    }
    componentDidMount() {
        this.getChannelList()
    }
}
